package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.MarketCoupon;
import com.cskaoyan.bean.MarketCouponUser;
import com.cskaoyan.bean.appletcoupon.CouponListVO;
import com.cskaoyan.bean.appletcoupon.CouponMylistVO;
import com.cskaoyan.bean.param.BaseParam;
import com.cskaoyan.service.AppletCouponService;
import com.cskaoyan.util.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * 创建日期: 2022/05/07 16:21
 *
 * @author liutao
 */
@RestController
public class AppletCouponController {

    @Autowired
    AppletCouponService appletCouponService;

    @RequestMapping("wx/coupon/list")
    public BaseRespVo couponList(BaseParam baseParam) {
        CouponListVO couponListVO = appletCouponService.couponList(baseParam);
        return BaseRespVo.ok(couponListVO);
    }

    @RequestMapping("wx/coupon/mylist")
    public BaseRespVo couponMylist(Integer status, BaseParam baseParam) {
        // 假设用户id=1
        // Integer id = 1;

        Integer id = AuthUtils.getUserId();
        CouponMylistVO couponMylistVO = appletCouponService.couponMylist(id, status, baseParam);
        return BaseRespVo.ok(couponMylistVO);
    }

    @RequestMapping("wx/coupon/selectlist")
    public BaseRespVo couponSelectlist(Integer cartId, Integer grouponRulesId) {
        // 假设用户id=1
        // Integer id = 1;

        Integer id = AuthUtils.getUserId();
        CouponMylistVO couponMylistVO = appletCouponService.couponSelectlist(id);
        return BaseRespVo.ok(couponMylistVO);
    }

    @RequestMapping("wx/coupon/receive")
    public BaseRespVo couponReceive(@RequestBody MarketCouponUser marketCouponUser) {
        // 假设用户id=1
        // Integer id = 1;

        Integer id = AuthUtils.getUserId();
        appletCouponService.couponReceive(id, marketCouponUser);
        return BaseRespVo.ok(null);
    }

    @RequestMapping("wx/coupon/exchange")
    public BaseRespVo couponExchange(MarketCoupon marketCoupon) {
        // 假设用户id=1
        // Integer id = 1;

        Integer id = AuthUtils.getUserId();
        appletCouponService.couponExchange(id, marketCoupon);
        return BaseRespVo.ok(null);
    }

}
